#!/usr/bin/env python3

import signal
import os
import time

def sig_handler(sig, stack):
    print("sig handler run.....sig = ", sig, ", pid = ", os.getpid())

def main():
    print("signal start...pid = ", os.getpid())
    signal.signal(signal.SIGINT, sig_handler)
    signal.signal(signal.SIGCHLD, sig_handler)
    signal.signal(signal.SIGTERM, sig_handler)
    if os.fork() == 0:
        print("child pid = %d" % (os.getpid()))
        time.sleep(60)
        os._exit(0)
    os.wait()
    print("signal end...")
    input()

if __name__ == "__main__":
    main()
